package com.android.videotest.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.util.Pair;

import com.android.videotest.JzViewOutlineProvider;
import com.android.videotest.R;
import com.android.videotest.Urls;

import java.io.IOException;
import java.util.ArrayList;

import cn.jzvd.JZDataSource;
import cn.jzvd.Jzvd;
import cn.jzvd.JzvdStd;

public class JiaoziPlayerActivity extends AppCompatActivity {
    public static void start(Context context) {
        Intent starter = new Intent(context, JiaoziPlayerActivity.class);
//    starter.putExtra();
        context.startActivity(starter);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_jiaozi_player);
        JzvdStd jiaozi = findViewById(R.id.video_View);

//        Uri uri = Uri.parse("android.resource://com.android.videotest/" + R.raw.test_vide);
//        videoView.setVideoURI(uri);
//        String url1 = "https://b2cimg.htd.cn/20191028104102_条码秤规则.mp4";
//        JZDataSource jzDataSource = null;
//        try {
//            jzDataSource = new JZDataSource(getAssets().openFd("test_vide.mp4"));
//            jzDataSource.title = "饺子快长大";
//        } catch (IOException e) {
//            Log.d(this.getClass().getName(), "onCreate:饺子快长大 " + e.getMessage());
//            e.printStackTrace();
//        }
//        jiaozi.setUp(jzDataSource, JzvdStd.SCREEN_NORMAL);
//        jiaozi.setUp(Urls.cacheVideoUrl(Urls.videoUrl), "");
        jiaozi.setUp("sdcard/qqmusic/mv/九尾 - 朱一龙、周冬雨、马思纯、李现、李沁《你好2020》_012ZPcFP1fVhRP_3_0 [mqms].mp4", "");
//        String url1 = "http://www.sansecy.com/downloader/download/test_vide.mp4";
        jiaozi.setOutlineProvider(new JzViewOutlineProvider(10));
        jiaozi.setClipToOutline(true);
//        jiaozi.setUp(url1.toString(), "");
        jiaozi.startVideo();
    }

    @Override
    protected void onStop() {
        super.onStop();
        Jzvd.releaseAllVideos();
    }
}
